package cn.com.allunion.sms.service.impl;

import cn.com.allunion.sms.service.TelaccsegmentService;
import com.cn.dao.util.HibernateDAO;
import com.cn.entity.Telaccsegment;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 过滤手机号码 业务逻辑接口实现类
 * Created by YangJie on 2016/4/13.
 */
@Service
public class TelaccsegmentServiceImpl implements TelaccsegmentService {

    private static final Logger LOGGER = LoggerFactory.getLogger(TelaccsegmentServiceImpl.class) ;

    /**
     * 依赖注入获得实体类操作模块实例
     */
    @Autowired
    HibernateDAO hibernateDao;

    @Override
    @Transactional(readOnly = true)
    public List<Telaccsegment> findTelaccsegment(String number) {
        LOGGER.debug("number.substring(0, 5)" + number.substring(0, 5));
        return hibernateDao.listByCriteria(Telaccsegment.class,
                Restrictions.like("acc_segment", number.substring(0, 5), MatchMode.START), true);
    }
}
